package com.example.meiyu.application;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by Administrator on 2016/6/14.
 */
public class SecondActivity extends AppCompatActivity {
    MyApp myApp;
    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
        SysApplication.getInstance().addActivity(this);
        tv= (TextView) findViewById(R.id.text);
        myApp=(MyApp) getApplication();
        Log.i("meiyu",myApp.getLabel());
        tv.setText(myApp.getLabel());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.item, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
//            case R.id.write_p:
//                // 当ActionBar图标被点击时调用
//                Intent intent=new Intent();
//                intent.setClass(MainActivity.this,OtherActivity.class);
//                startActivity(intent);
//                Toast.makeText(this, "你点击了“发布”按键！", Toast.LENGTH_SHORT).show();
//                return true;

            case R.id.favo_p1:
                Toast.makeText(this, "你点击了“加菜”按键！", Toast.LENGTH_SHORT).show();
                return true;

            case R.id.favo_p3:
                Intent intent=new Intent();
                intent.setClass(SecondActivity.this,ThirdActivity.class);
                startActivity(intent);
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
